package com.tedu.parkinglot.blakname.service.impl;

import com.tedu.parkinglot.blakname.mapper.BlackNameMapper;
import com.tedu.parkinglot.blakname.pojo.dto.BlackNameParam;
import com.tedu.parkinglot.blakname.pojo.dto.BlackNameQuery;
import com.tedu.parkinglot.blakname.pojo.entity.BlackName;
import com.tedu.parkinglot.blakname.pojo.vo.BlackNameVO;
import com.tedu.parkinglot.blakname.service.BlackNameService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Slf4j
@Service
public class BlackNameServiceImpl implements BlackNameService {
    @Autowired
    private BlackNameMapper blackNameMapper;
    @Override
    public List<BlackNameVO> select(BlackNameQuery blackNameQuery) {
        log.debug("查询黑名单业务:BlackNameQuery:{}", blackNameQuery);
        List<BlackNameVO> list = blackNameMapper.select(blackNameQuery);
        log.debug("查询结果:list={}",list);
        return list;
    }

    @Override
    public void insert(BlackNameParam blackNameParam) {
        log.debug("新增黑名单业务:BlackNameParam:{}", blackNameParam);
        BlackName blackName = new BlackName();
        BeanUtils.copyProperties(blackNameParam, blackName);
        blackName.setCreateTime(new Date());
        blackName.setAudit("10");
        blackName.setAddtime(new Date());
        blackName.setAuditTime(new Date());
        blackNameMapper.insert(blackName);
    }
    @Override
    public void update(BlackNameParam blackNameParam) {
        log.debug("更新黑名单业务:BlackNameParam:{}", blackNameParam);
        BlackName blackName = new BlackName();
        BeanUtils.copyProperties(blackNameParam, blackName);
        blackName.setUpdateTime(new Date());
        blackName.setAuditTime(new Date());
        blackNameMapper.update(blackName);
    }


}
